package com.itheima.service.impl;

import com.itheima.dao.UserDao;
import com.itheima.dao.impl.UserDaoImpl;
import com.itheima.pojo.User;
import com.itheima.service.UserService;

/**
 * @author ：seanyang
 * @date ：Created in 2019/4/28
 * @description ：用户Service实现类
 * @version: 1.0
 */
public class UserServiceImpl implements UserService {

    //创建UserDAO对象
    private UserDao userDao = new UserDaoImpl();

    //注册
    @Override
    public boolean register(User user) {
        //定义一个boolean类型返回值
        boolean flag = false;
        //调用Dao层方法
        try {
            userDao.register(user);
            //注册成功后变为true
            flag = true;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return flag;
    }

    //登陆
    @Override
    public User login(String username, String password) {
        User user = null;
        //调用Dao层方法
        try {
            user = userDao.login(username, password);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return user;
    }

}
